home *** CD-ROM | disk | FTP | other *** search
/ PC Plus SuperCD (UK) 1998 August / PC Plus SuperCD 50b Issue 142 (CD142b) (August 1998).iso / handson / Java / sc20form.jar / com / supercede / forms / SuperCedeDesignInfo.class (.txt) < prev    next >
Encoding:
Java Class File  |  1998-01-28  |  8.5 KB  |  527 lines

  1. package com.supercede.forms;
  2.  
  3. import java.awt.CheckboxGroup;
  4. import java.awt.Color;
  5. import java.awt.Component;
  6. import java.awt.Dimension;
  7. import java.io.Serializable;
  8. import java.util.Vector;
  9.  
  10. public class SuperCedeDesignInfo implements Serializable {
  11.    protected boolean multithreaded = false;
  12.    protected Vector radioGroupList = new Vector();
  13.    public static final int VERTICAL = 0;
  14.    public static final int HORIZONTAL = 1;
  15.    protected boolean preferencesSet = false;
  16.    protected Dimension absoluteSize;
  17.    protected Vector componentList;
  18.    private long nextComponentID = 1L;
  19.    protected long leftMargin;
  20.    protected long rightMargin;
  21.    protected long topMargin;
  22.    protected long bottomMargin;
  23.    private long nextGuideID = 1L;
  24.    protected Vector guideList;
  25.    protected Color marginColor;
  26.    protected Color guideColor;
  27.    protected Color[] customColor;
  28.    protected boolean markSnap;
  29.    protected long markSpacing;
  30.    protected long gravity;
  31.    protected long rulerZoneSize;
  32.    protected boolean tabOrderVisible;
  33.    protected boolean rulersVisible;
  34.    protected boolean rulerTicksVisible;
  35.    protected boolean statusBarVisible;
  36.    protected boolean toolbarVisible;
  37.    protected boolean javaPaletteVisible;
  38.    protected boolean activeXPaletteVisible;
  39.    private static final long serialVersionUID = 1013082004010516617L;
  40.    private static final int _version = 1;
  41.    private int version = 1;
  42.  
  43.    public SuperCedeDesignInfo() {
  44.       this.addRadioGroup("group1");
  45.       this.componentList = new Vector();
  46.       this.absoluteSize = new Dimension(300, 160);
  47.       this.leftMargin = 0L;
  48.       this.rightMargin = 0L;
  49.       this.topMargin = 0L;
  50.       this.bottomMargin = 0L;
  51.       this.guideList = new Vector();
  52.       this.marginColor = new Color(128, 0, 128);
  53.       this.guideColor = new Color(64, 128, 128);
  54.       this.customColor = new Color[16];
  55.  
  56.       for(int var1 = 0; var1 < this.customColor.length; ++var1) {
  57.          this.customColor[var1] = Color.white;
  58.       }
  59.  
  60.       this.markSnap = false;
  61.       this.markSpacing = 10L;
  62.       this.gravity = 200L;
  63.       this.rulerZoneSize = 1200L;
  64.       this.tabOrderVisible = false;
  65.       this.rulersVisible = true;
  66.       this.rulerTicksVisible = true;
  67.       this.statusBarVisible = true;
  68.       this.toolbarVisible = true;
  69.       this.javaPaletteVisible = true;
  70.       this.activeXPaletteVisible = true;
  71.    }
  72.  
  73.    public boolean isMultithreaded() {
  74.       return this.multithreaded;
  75.    }
  76.  
  77.    public void setMultithreaded(boolean var1) {
  78.       this.multithreaded = var1;
  79.    }
  80.  
  81.    public synchronized void addRadioGroup(String var1) {
  82.       if (this.findRadioGroup(var1) < 0) {
  83.          this.radioGroupList.addElement(new RadioGroupInfo(var1, new CheckboxGroup()));
  84.       }
  85.  
  86.    }
  87.  
  88.    public synchronized boolean removeRadioGroup(String var1) {
  89.       int var3 = this.findRadioGroup(var1);
  90.       boolean var2;
  91.       if (var3 < 0) {
  92.          var2 = false;
  93.       } else {
  94.          try {
  95.             this.radioGroupList.removeElementAt(var3);
  96.             var2 = true;
  97.          } catch (ArrayIndexOutOfBoundsException var4) {
  98.             var2 = false;
  99.          }
  100.       }
  101.  
  102.       return var2;
  103.    }
  104.  
  105.    public synchronized CheckboxGroup getRadioGroup(String var1) {
  106.       int var3 = this.findRadioGroup(var1);
  107.       CheckboxGroup var2;
  108.       if (var3 < 0) {
  109.          var2 = null;
  110.       } else {
  111.          try {
  112.             RadioGroupInfo var4 = (RadioGroupInfo)this.radioGroupList.elementAt(var3);
  113.             var2 = var4.radioGroup;
  114.          } catch (ArrayIndexOutOfBoundsException var5) {
  115.             var2 = null;
  116.          }
  117.       }
  118.  
  119.       return var2;
  120.    }
  121.  
  122.    public synchronized String[] getRadioGroupNames() {
  123.       int var2 = this.radioGroupList.size();
  124.       String[] var1;
  125.       if (var2 == 0) {
  126.          var1 = null;
  127.       } else {
  128.          var1 = new String[var2];
  129.  
  130.          for(int var3 = 0; var3 < var2; ++var3) {
  131.             RadioGroupInfo var4;
  132.             try {
  133.                var4 = (RadioGroupInfo)this.radioGroupList.elementAt(var3);
  134.             } catch (ArrayIndexOutOfBoundsException var5) {
  135.                var4 = null;
  136.             }
  137.  
  138.             var1[var3] = var4.name;
  139.          }
  140.       }
  141.  
  142.       return var1;
  143.    }
  144.  
  145.    public boolean preferencesAreApplied() {
  146.       return this.preferencesSet;
  147.    }
  148.  
  149.    public void initializedFromPreferences() {
  150.       this.preferencesSet = true;
  151.    }
  152.  
  153.    public Dimension getAbsoluteSize() {
  154.       return this.absoluteSize;
  155.    }
  156.  
  157.    public void setAbsoluteSize(Dimension var1) {
  158.       this.absoluteSize = var1;
  159.    }
  160.  
  161.    public int getComponentCount() {
  162.       return this.componentList.size();
  163.    }
  164.  
  165.    public synchronized long addComponent(Component var1) {
  166.       long var2 = (long)(this.nextComponentID++);
  167.       this.componentList.addElement(new ComponentInfo(var2, var1));
  168.       return var2;
  169.    }
  170.  
  171.    public void addComponent(long var1, Component var3) {
  172.       this.componentList.addElement(new ComponentInfo(var1, var3));
  173.    }
  174.  
  175.    public void removeComponent(int var1) throws ArrayIndexOutOfBoundsException {
  176.       try {
  177.          this.componentList.removeElementAt(var1);
  178.       } catch (ArrayIndexOutOfBoundsException var3) {
  179.          throw var3;
  180.       }
  181.    }
  182.  
  183.    public int findComponent(long var1) {
  184.       int var3 = 0;
  185.  
  186.       int var4;
  187.       for(var4 = this.getComponentCount(); var3 < var4; ++var3) {
  188.          ComponentInfo var5;
  189.          try {
  190.             var5 = (ComponentInfo)this.componentList.elementAt(var3);
  191.          } catch (ArrayIndexOutOfBoundsException var6) {
  192.             var5 = null;
  193.          }
  194.  
  195.          if (var5 == null) {
  196.             var3 = var4;
  197.             break;
  198.          }
  199.  
  200.          if (var5.id == var1) {
  201.             break;
  202.          }
  203.       }
  204.  
  205.       return var3 >= var4 ? -1 : var3;
  206.    }
  207.  
  208.    public int findComponent(Component var1) {
  209.       int var2 = 0;
  210.  
  211.       int var3;
  212.       for(var3 = this.getComponentCount(); var2 < var3; ++var2) {
  213.          ComponentInfo var4;
  214.          try {
  215.             var4 = (ComponentInfo)this.componentList.elementAt(var2);
  216.          } catch (ArrayIndexOutOfBoundsException var5) {
  217.             var4 = null;
  218.          }
  219.  
  220.          if (var4 == null) {
  221.             var2 = var3;
  222.             break;
  223.          }
  224.  
  225.          if (var4.component == var1) {
  226.             break;
  227.          }
  228.       }
  229.  
  230.       return var2 >= var3 ? -1 : var2;
  231.    }
  232.  
  233.    public Component getComponent(int var1) throws ArrayIndexOutOfBoundsException {
  234.       ComponentInfo var2;
  235.       try {
  236.          var2 = (ComponentInfo)this.componentList.elementAt(var1);
  237.       } catch (ArrayIndexOutOfBoundsException var4) {
  238.          throw var4;
  239.       }
  240.  
  241.       return var2.component;
  242.    }
  243.  
  244.    public long getComponentID(int var1) throws ArrayIndexOutOfBoundsException {
  245.       ComponentInfo var2;
  246.       try {
  247.          var2 = (ComponentInfo)this.componentList.elementAt(var1);
  248.       } catch (ArrayIndexOutOfBoundsException var4) {
  249.          throw var4;
  250.       }
  251.  
  252.       return var2.id;
  253.    }
  254.  
  255.    public long getLeftMargin() {
  256.       return this.leftMargin;
  257.    }
  258.  
  259.    public void setLeftMargin(long var1) {
  260.       this.leftMargin = var1;
  261.    }
  262.  
  263.    public long getRightMargin() {
  264.       return this.rightMargin;
  265.    }
  266.  
  267.    public void setRightMargin(long var1) {
  268.       this.rightMargin = var1;
  269.    }
  270.  
  271.    public long getTopMargin() {
  272.       return this.topMargin;
  273.    }
  274.  
  275.    public void setTopMargin(long var1) {
  276.       this.topMargin = var1;
  277.    }
  278.  
  279.    public long getBottomMargin() {
  280.       return this.bottomMargin;
  281.    }
  282.  
  283.    public void setBottomMargin(long var1) {
  284.       this.bottomMargin = var1;
  285.    }
  286.  
  287.    public int getGuideCount() {
  288.       return this.guideList.size();
  289.    }
  290.  
  291.    public synchronized long addGuide(int var1, long var2) {
  292.       long var4 = (long)(this.nextGuideID++);
  293.       this.guideList.addElement(new GuideInfo(var1, var4, var2));
  294.       return var4;
  295.    }
  296.  
  297.    public void addGuide(long var1, int var3, long var4) {
  298.       this.guideList.addElement(new GuideInfo(var3, var1, var4));
  299.    }
  300.  
  301.    public void removeGuide(int var1) throws ArrayIndexOutOfBoundsException {
  302.       try {
  303.          this.guideList.removeElementAt(var1);
  304.       } catch (ArrayIndexOutOfBoundsException var3) {
  305.          throw var3;
  306.       }
  307.    }
  308.  
  309.    public int findGuide(long var1) {
  310.       int var3 = 0;
  311.  
  312.       int var4;
  313.       for(var4 = this.getGuideCount(); var3 < var4; ++var3) {
  314.          GuideInfo var5;
  315.          try {
  316.             var5 = (GuideInfo)this.guideList.elementAt(var3);
  317.          } catch (ArrayIndexOutOfBoundsException var6) {
  318.             var5 = null;
  319.          }
  320.  
  321.          if (var5 == null) {
  322.             var3 = var4;
  323.             break;
  324.          }
  325.  
  326.          if (var5.id == var1) {
  327.             break;
  328.          }
  329.       }
  330.  
  331.       return var3 >= var4 ? -1 : var3;
  332.    }
  333.  
  334.    public int getGuideAspect(int var1) throws ArrayIndexOutOfBoundsException {
  335.       GuideInfo var2;
  336.       try {
  337.          var2 = (GuideInfo)this.guideList.elementAt(var1);
  338.       } catch (ArrayIndexOutOfBoundsException var4) {
  339.          throw var4;
  340.       }
  341.  
  342.       return var2.aspect;
  343.    }
  344.  
  345.    public long getGuideID(int var1) throws ArrayIndexOutOfBoundsException {
  346.       GuideInfo var2;
  347.       try {
  348.          var2 = (GuideInfo)this.guideList.elementAt(var1);
  349.       } catch (ArrayIndexOutOfBoundsException var4) {
  350.          throw var4;
  351.       }
  352.  
  353.       return var2.id;
  354.    }
  355.  
  356.    public long getGuidePosition(int var1) throws ArrayIndexOutOfBoundsException {
  357.       GuideInfo var2;
  358.       try {
  359.          var2 = (GuideInfo)this.guideList.elementAt(var1);
  360.       } catch (ArrayIndexOutOfBoundsException var4) {
  361.          throw var4;
  362.       }
  363.  
  364.       return var2.position;
  365.    }
  366.  
  367.    public void setGuidePosition(int var1, long var2) throws ArrayIndexOutOfBoundsException {
  368.       GuideInfo var4;
  369.       try {
  370.          var4 = (GuideInfo)this.guideList.elementAt(var1);
  371.       } catch (ArrayIndexOutOfBoundsException var6) {
  372.          throw var6;
  373.       }
  374.  
  375.       var4.position = var2;
  376.    }
  377.  
  378.    public Color getMarginColor() {
  379.       return this.marginColor;
  380.    }
  381.  
  382.    public void setMarginColor(Color var1) {
  383.       this.marginColor = var1;
  384.    }
  385.  
  386.    public Color getGuideColor() {
  387.       return this.guideColor;
  388.    }
  389.  
  390.    public void setGuideColor(Color var1) {
  391.       this.guideColor = var1;
  392.    }
  393.  
  394.    public int getCustomColorCount() {
  395.       return this.customColor.length;
  396.    }
  397.  
  398.    public Color getCustomColor(int var1) throws ArrayIndexOutOfBoundsException {
  399.       try {
  400.          return this.customColor[var1];
  401.       } catch (ArrayIndexOutOfBoundsException var3) {
  402.          throw var3;
  403.       }
  404.    }
  405.  
  406.    public void setCustomColor(int var1, Color var2) throws ArrayIndexOutOfBoundsException {
  407.       try {
  408.          this.customColor[var1] = var2;
  409.       } catch (ArrayIndexOutOfBoundsException var4) {
  410.          throw var4;
  411.       }
  412.    }
  413.  
  414.    public boolean getMarkSnap() {
  415.       return this.markSnap;
  416.    }
  417.  
  418.    public void setMarkSnap(boolean var1) {
  419.       this.markSnap = var1;
  420.    }
  421.  
  422.    public long getMarkSpacing() {
  423.       return this.markSpacing;
  424.    }
  425.  
  426.    public void setMarkSpacing(long var1) {
  427.       this.markSpacing = var1;
  428.    }
  429.  
  430.    public long getGravity() {
  431.       return this.gravity;
  432.    }
  433.  
  434.    public void setGravity(long var1) {
  435.       this.gravity = var1;
  436.    }
  437.  
  438.    public long getRulerZoneSize() {
  439.       return this.rulerZoneSize;
  440.    }
  441.  
  442.    public void setRulerZoneSize(long var1) {
  443.       this.rulerZoneSize = var1;
  444.    }
  445.  
  446.    public boolean isTabOrderVisible() {
  447.       return this.tabOrderVisible;
  448.    }
  449.  
  450.    public void setTabOrderVisible(boolean var1) {
  451.       this.tabOrderVisible = var1;
  452.    }
  453.  
  454.    public boolean isRulersVisible() {
  455.       return this.rulersVisible;
  456.    }
  457.  
  458.    public void setRulersVisible(boolean var1) {
  459.       this.rulersVisible = var1;
  460.    }
  461.  
  462.    public boolean isRulerTicksVisible() {
  463.       return this.rulerTicksVisible;
  464.    }
  465.  
  466.    public void setRulerTicksVisible(boolean var1) {
  467.       this.rulerTicksVisible = var1;
  468.    }
  469.  
  470.    public boolean isStatusBarVisible() {
  471.       return this.statusBarVisible;
  472.    }
  473.  
  474.    public void setStatusBarVisible(boolean var1) {
  475.       this.statusBarVisible = var1;
  476.    }
  477.  
  478.    public boolean isToolbarVisible() {
  479.       return this.toolbarVisible;
  480.    }
  481.  
  482.    public void setToolbarVisible(boolean var1) {
  483.       this.toolbarVisible = var1;
  484.    }
  485.  
  486.    public boolean isJavaPaletteVisible() {
  487.       return this.javaPaletteVisible;
  488.    }
  489.  
  490.    public void setJavaPaletteVisible(boolean var1) {
  491.       this.javaPaletteVisible = var1;
  492.    }
  493.  
  494.    public boolean isActiveXPaletteVisible() {
  495.       return this.activeXPaletteVisible;
  496.    }
  497.  
  498.    public void setActiveXPaletteVisible(boolean var1) {
  499.       this.activeXPaletteVisible = var1;
  500.    }
  501.  
  502.    private int findRadioGroup(String var1) {
  503.       int var2 = 0;
  504.  
  505.       int var3;
  506.       for(var3 = this.radioGroupList.size(); var2 < var3; ++var2) {
  507.          RadioGroupInfo var4;
  508.          try {
  509.             var4 = (RadioGroupInfo)this.radioGroupList.elementAt(var2);
  510.          } catch (ArrayIndexOutOfBoundsException var5) {
  511.             var4 = null;
  512.          }
  513.  
  514.          if (var4 == null) {
  515.             var2 = var3;
  516.             break;
  517.          }
  518.  
  519.          if (var4.name.equals(var1)) {
  520.             break;
  521.          }
  522.       }
  523.  
  524.       return var2 >= var3 ? -1 : var2;
  525.    }
  526. }
  527.